

class Member:
    def __init__(self, n, score) -> None:
        self.number = n
        self.score = score


def key(member):
    s = member.score
    score = s.count('1')
    combo = max([len(tmpCombo) for tmpCombo in iter(s.split('0'))])
    return [score, combo, s]


n, m = map(int, input().split())
scores = input().split()
records = []
for i in range(n):
    records.append(Member(i+1, scores[i]))

ans = sorted(records, key=key, reverse=True)
for element in ans:
    # print(element.number, key(element))
    print(element.number, end=' ')
